package com.yuyao.myapplication

import android.app.Application
import android.util.Log
import androidx.lifecycle.AndroidViewModel
import androidx.lifecycle.LiveData
import androidx.lifecycle.viewModelScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch

class AppViewModel(app: Application): AndroidViewModel(app) {



    init {

        viewModelScope.launch(Dispatchers.IO){
        Log.e("AppViewModel", "ok")
        var personDao = PersonDatabase.getDatabase(app).personDao()

        var items = personDao.readAll()



            personDao.addPerson(Person(name="222"))


            personDao.addPerson(Person(name="222"))


        addPerson(Person(name = "OK"))
        addPerson(Person(name = "OK"))



        Log.e("AppViewModel OK", "ok" + items.size)
    }

    }


    fun addPerson(person:Person)
    {

        viewModelScope.launch{


        }

    }

}